
    function sendMultipleMessage() {
    	var  arr = ['1297092863'];
    	var list = JSON.parse($.cookie("friendList")).data ;
    	for ( i = 0; i < list.length; i++) {
    	    arr.push(list[i].id);
    	}
    	
        FB.getLoginStatus(function (response) {
            FB.ui({
                     method: "send",
                     app_id:184484190795,
                     to:[511353522, '4'],
                     picture: $('#imageUrl').val(),
                     link: $('#messageLink').val(),
                     description:'avc' ,//$('#conversationText').val(),
                     name: "Join my site, now!",
                     display: 'popup'
                 },
                 function (param) {
                     if (!param.success){
                         $('li[id*=pre]').click();
                     }
                     else{
                            $('div[id*=box]').animate({ 'top': '-500px' }, 500, function () {
                            $('#overlay').fadeOut('fast');
                            });
                     }
                });
             });
      }
   
   
//*************************************************************************************************************
   
    function sendfeed() {
      FB.getLoginStatus(function (response) {
        FB.ui(
            {
              method: 'feed',
              to: '100002126219072',
              from:'1297092863',
              tags:'100002829810133',
              name: 'Facebook Dialogs',
              link: $('#messageLink').val(),
              picture: $('#imageUrl').val(),
              caption: 'Reference Documentation',
              description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
            },
            function(response) {
              if (response && response.post_id) {
                alert('Post was published.');
              } else {
                alert('Post was not published.');
              }
            }
          );
      });
    }

//*************************************************************************************************************    
   
    function sendMessageRead(){
      //document.domain= 'facebook.com';
      //alert($(".FB_UI_Dialog").contents().find("feedform_user_message").val());
    	  //var strUrl = 'https://www.facebook.com/dialog/send?to=%5B1297092863%2C%22100002829810133%22%5D&name=Join%20my%20site%2C%20now!&description=...&link=http%3A%2F%2Fwww.cutoutandkeep.net&display=popup&e2e=%7B%7D&app_id=184484190795&locale=en_US&sdk=joey&access_token=CAAAAKvQdWksBADpTYofJTokN4FkbKm0FtatWFBsZAe8yJw67zeSbnbFgOZBBVIjNNIuTto3eBaWrNbL5U0pwafmjVHK6LKgjZCusCO2AbZCY05ahuvgQJUEOroYEqyVOJHTZBycvsvMFPfHDbNEKrx8K35HalDcEZD&next=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D25%23cb%3Dffc80721599782%26origin%3Dhttp%253A%252F%252Fwww.fbrell.com%252Ff31067ba6b5f6f4%26domain%3Dwww.fbrell.com%26relation%3Dopener%26frame%3Dff043118376eba%26result%3D%2522xxRESULTTOKENxx%2522';
    	var strUrl = 'www.google.com';
          FB.getLoginStatus(function (response) {
   	       $.ajax({ 
   	    	    type: 'POST',
   	            url: strUrl,
   	            success: function (response) {
   	                console.log(response);
   	            },
   	            error: function(error) {
   	            	console.log(strUrl);
   	                alert(error.status);
   	            }
   	        });
          });
    }

//*************************************************************************************************************
   
    function SendEmail() {
        //Call webservice to send e-mail e.g.
       var strUrl = 'https://www.facebook.com/dialog/send?app_id='+ $('#appId').val() +'&to=100002126219072&link=http://www.cymax.com/South-Shore-3070-23X-Lexington-Platform-Bed.htm&redirect_uri=http://localhost:8888/base.html'
       FB.getLoginStatus(function (response) {
	       $.ajax({ 
	    	    type: 'POST',
	            url: strUrl,
	            success: function (response) {
	                console.log(response);
	            },
	            error: function(error) {
	                console.log(strUrl);
	                alert(error.status);
	            }
	        });
       });
    }
   
//*************************************************************************************************************
   function sendNotifications(contacts,callback){
	 for (var i = 0; i < contacts.length; i++) {
		 sendANotification(contacts[i].id,$("#fbid").val());
		 console.log('Notifing to' + contacts[i]);
		 callback.call();
	 }
	 
   }
   
    function sendANotification(contactId,senderId) {
      var param = 'https://apps.facebook.com/'+ $('#appId').val()+'/fb_source=myapps' ;
//      var tempdata = {};
//      tempdata['access_token'] = $('#appAccessToken').val();
//      tempdata['href'] = param;
//      tempdata['template'] = 'started a game with you!';
//      data: JSON.stringify(tempdata),    
//      dataType: 'json',
//      console.log(JSON.stringify(tempdata));
      var strUrl = 'https://graph.facebook.com/'+ contactId +'/notifications?access_token=' + $('#appAccessToken').val() + '&href=' + param + '&template= @['+senderId+'] needs to have your idea!' 
      FB.getLoginStatus(function (response) {
        $.ajax({ type: 'POST',
            url:strUrl,
            success: function (response) {
                console.log(response);
            },
            error: function(error) {
            	var date = new Date();
            	date.setTime(date.getTime() + (60 * 1000));
            	if(error.status=='403' || error.status=='200'){
            		var tempdata = {
                			"data" : [{"id":contactId}]
                        };
	            	if($.cookie("friendListNotAllowed") == 'null'){
	                	$.cookie("friendListNotAllowed", JSON.stringify(tempdata),date);
	                }
	                else{
	                	 jsonFriendList = JSON.parse($.cookie("friendListNotAllowed"));
	                     jsonFriendList.data.push(tempdata.data[0]);
	                     $.cookie("friendListNotAllowed", JSON.stringify(jsonFriendList),date);
	                }
            	}
            }
        });
      });
    }
       
//*************************************************************************************************************
       
    function getContent(){
      var response = '';
      $.ajax({
        type: "GET",  
        url: $('#messageLink').val(),
        async: false,
            success : function(text)
            {
                response = text;
            }
         });
          alert(response);
     }
       
//*************************************************************************************************************        
       
    function getImage(){
      $.ajax({
        url:  $('#messageLink').val(),
        beforeSend: function ( xhr ) {
        xhr.overrideMimeType("text/plain; charset=x-user-defined");
        }
        }).done(function ( data ) {
        if( console && console.log ) {
        console.log("Sample of data:", data.slice(0, 100));
        }
        });
    }
   
   
  //*************************************************************************************************************


    function createList(text) {
      FB.getLoginStatus(function (response) {
	   var response = '';
	      $.ajax({
	        type: "POST",  
	        url: "https://graph.facebook.com/1297092863/friendlists/New/?access_token=CAATyYP237qABAMwnGbCui5M7bZAaqgd3QYO56YqErBXld3UZB7x5ZCe9MgbIcpmkKlbnfpd3SeuzOr60Put5wyW0ZB0DxxrBdhjDZC2ISDPEkb2I7T6uezWxCLZADwtKLvSFCwTuXZAELATe1gDnZCRVZBNJqw8LKpQ0SKL7abNiYxwZDZD",
	        async: false,
            success : function(text)
            {
                response = text;
            }
         });
	          alert(response);
      });
    }
//        }).done(function ( data ) {
//        if( console && console.log ) {
//        console.log("Sample of data:", data.slice(0, 100));
//        }
//        });
    